package com.ftg.learnmybatis.learnio;

import org.apache.ibatis.javassist.scopedpool.SoftValueHashMap;

import java.io.*;

/**
 * 缓冲区
 *
 * @author kangjx
 * @version 1.0
 * @date 2023/3/13 下午3:00
 */
public class Example04 {

    public static void main(String[] args) {
//        带缓冲区的 输入流
        try (
                BufferedReader bufferedReader = new BufferedReader(new FileReader("/home/kangjx/Desktop/abc.txt"));
                BufferedWriter wirte = new BufferedWriter(new FileWriter("/home/kangjx/Desktop/abc2.txt"))
        ) {

//            while(bufferedReader.ready()){
//                wirte.write(bufferedReader.read());
//            }
             String str = "";
             while((str = bufferedReader.readLine()) != null){
                 System.out.println(str);
                 wirte.write(str +"\n");
             }

            wirte.flush();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

}
